package com.zjm.servlet.servlet05_config_context;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ZJM
 * @date 2024/4/12 23:00
 * 获取ServletContext中的数据,
 * web工程停止ServletContext对象销毁，数据全部清空
 */
public class ServletContextTest03Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();
        System.out.println("ServletContextTest03Servlet:" + servletContext.getAttribute("key1"));
    }
}
